package fr.inserm.umr915.vcfserver.bio.ucsc.kgxref;

import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

import fr.inserm.umr915.vcfserver.xml.XmlStreamSerializer;

public class KgXRef
	{
	private String kgID;
	private String mRNA;
	private String spID;
	private String spDisplayID;
	private String geneSymbol;
	private String refseq;
	private String protAcc;
	private String description;
	public KgXRef()
	   {
	   }
	public String getKgID()
	   {
	   return this.kgID;
	   }
	public String getMRNA()
	   {
	   return this.mRNA;
	   }
	public String getSpID()
	   {
	   return this.spID;
	   }
	public String getSpDisplayID()
	   {
	   return this.spDisplayID;
	   }
	public String getGeneSymbol()
	   {
	   return this.geneSymbol;
	   }
	public String getRefseq()
	   {
	   return this.refseq;
	   }
	public String getProtAcc()
	   {
	   return this.protAcc;
	   }
	public String getDescription()
	   {
	   return this.description;
	   }
	@Override
	public String toString()
	   {
	   return this.getClass().toString() +  " 'kgID'= " + this.kgID +  " 'mRNA'= " + this.mRNA +  " 'spID'= " + this.spID +  " 'spDisplayID'= " + this.spDisplayID +  " 'geneSymbol'= " + this.geneSymbol +  " 'refseq'= " + this.refseq +  " 'protAcc'= " + this.protAcc +  " 'description'= " + this.description;
	   }
	
	
	
	
	
	  /** XMLStreamWriter serialisation */
	  public static class StaxSerializer implements XmlStreamSerializer<KgXRef>
		  {
		  @Override
		  public void write(KgXRef o,javax.xml.stream.XMLStreamWriter w) throws javax.xml.stream.XMLStreamException
			  {
			  w.writeStartElement("KgXref");
			  w.writeStartElement("kgID");
			  w.writeCharacters(String.valueOf(o.getKgID()));
			  w.writeEndElement();
			  if(o.getMRNA()!=null && !o.getMRNA().isEmpty())
				  {
				  w.writeStartElement("mRNA");
				  w.writeCharacters(String.valueOf(o.getMRNA()));
				  w.writeEndElement();
				  }
			  if(o.getSpID()!=null  && !o.getSpID().isEmpty())
				  {
				  w.writeStartElement("spID");
				  w.writeCharacters(String.valueOf(o.getSpID()));
				  w.writeEndElement();
				  }
			  if(o.getSpDisplayID()!=null  && !o.getSpDisplayID().isEmpty())
				  {
				  w.writeStartElement("spDisplayID");
				  w.writeCharacters(String.valueOf(o.getSpDisplayID()));
				  w.writeEndElement();
				  }
			  if(o.getGeneSymbol()!=null  && !o.getGeneSymbol().isEmpty())
				  {
				  w.writeStartElement("geneSymbol");
				  w.writeCharacters(String.valueOf(o.getGeneSymbol()));
				  w.writeEndElement();
				  }
			  if(o.getRefseq()!=null  && !o.getRefseq().isEmpty())
				  {
				  w.writeStartElement("refseq");
				  w.writeCharacters(String.valueOf(o.getRefseq()));
				  w.writeEndElement();
				  }
			  if(o.getProtAcc()!=null  && !o.getProtAcc().isEmpty())
				  {
				  w.writeStartElement("protAcc");
				  w.writeCharacters(String.valueOf(o.getProtAcc()));
				  w.writeEndElement();
				  }
			  w.writeStartElement("description");
			  w.writeCharacters(String.valueOf(o.getDescription()));
			  w.writeEndElement();
			  w.writeEndElement();
}
		  }


	
	   public static KgXRef parse(String tokens[])
	      {
		   KgXRef o=new KgXRef();
	      o.kgID=tokens[0];
	      o.mRNA=tokens[1];
	      o.spID=tokens[2];
	      o.spDisplayID=tokens[3];
	      o.geneSymbol=tokens[4];
	      o.refseq=tokens[5];
	      o.protAcc=tokens[6];
	      o.description=tokens[7];
	      return o;
	      }
	   
	public static class Binding extends TupleBinding<KgXRef>
	   {
	   @Override
	   public KgXRef entryToObject(TupleInput in)
	      	{
		   KgXRef o=new KgXRef();
			o.kgID=in.readString();
			if(!in.readBoolean()) {o.mRNA=in.readString();} else {o.mRNA=null;}
			if(!in.readBoolean()) {o.spID=in.readString();} else {o.spID=null;}
			if(!in.readBoolean()) {o.spDisplayID=in.readString();} else {o.spDisplayID=null;}
			if(!in.readBoolean()) {o.geneSymbol=in.readString();} else {o.geneSymbol=null;}
			if(!in.readBoolean()) {o.refseq=in.readString();} else {o.refseq=null;}
			if(!in.readBoolean()) {o.protAcc=in.readString();} else {o.protAcc=null;}
			o.description=in.readString();
			return o;
	      	}
	   
	   @Override
	   public void objectToEntry(KgXRef o,TupleOutput out)
	      	{
			out.writeString(o.kgID);
			out.writeBoolean(o.mRNA==null); if(o.mRNA!=null) {out.writeString(o.mRNA);}
			out.writeBoolean(o.spID==null); if(o.spID!=null) {out.writeString(o.spID);}
			out.writeBoolean(o.spDisplayID==null); if(o.spDisplayID!=null) {out.writeString(o.spDisplayID);}
			out.writeBoolean(o.geneSymbol==null); if(o.geneSymbol!=null) {out.writeString(o.geneSymbol);}
			out.writeBoolean(o.refseq==null); if(o.refseq!=null) {out.writeString(o.refseq);}
			out.writeBoolean(o.protAcc==null); if(o.protAcc!=null) {out.writeString(o.protAcc);}
			out.writeString(o.description);
	      	}
	   }
	}
